let mongoose = require('&/db')

let UserSchema = mongoose.Schema({
  name: {type: String, required: true},
  password: {type: String, required: true, select: false},
  avatar: {type: String},
  gender: {type: String, enum: ['male', 'female'], default: 'male', required: true},
  headline: {type: String},
  locations: {type: [{type: String}], select: false},
  business: {type: String, select: false},
  employments: {
    type: [{
      company: {type: String},
      job: {type: String}
    }],
    select: false
  },
  educations: {
    type: [{
      school: {type: String},
      major: {type: String},
      diploma: {type: Number, enum: [1, 2, 3, 4, 5]},
      entrance_year: {type: Number},
      graduation_year: {type: Number}
    }],
    select: false
  },
  following: {
    type: [{type: mongoose.Schema.Types.ObjectId, ref: 'User'}],
    select: false
  }
})


let UserModel = mongoose.model('User', UserSchema, 'user')

module.exports = UserModel
